const mongoose = require("./db");
const MenuSchema = new mongoose.Schema({
  key: String,
  label: String,
  icon: String,
  pid: {
    type: mongoose.Types.ObjectId,
    ref: "Menu"
  }
});

<<<<<<< HEAD
const RoleSchema = new mongoose.Schema({
  role: String,
  menus: {
    type: [mongoose.Types.ObjectId],
    ref: "Menu"
  }
});

const zsySchema = mongoose.Schema({
  name: String
});
=======
>>>>>>> 40cb69444077c79252235744ae50d4b0bd554708

const RoleSchema = mongoose.Schema({
    role:String,
    menus:{
        type:mongoose.Types.ObjectId,
        ref:'Menu'
    }
})


//创建排班表
const ClassesSchema = mongoose.Schema({
  year: Number,
  month: Number,
  day: Number,
  classesName: String, //班次名称
  startTime: String, //开始时间
  endTime: String, //结束时间
  workTime: String, //上班时间
  endWorkTime: String, //下班时间
  user: {
    type: mongoose.Types.ObjectId,
    ref: "User"
  },
  //是否缺勤
  isAbsent: {
    type: Boolean,
    default: false
  },
  //是否请假
  isLeave: {
    type: Boolean,
    default: false
  }
});

const UserSchema = mongoose.Schema({
<<<<<<< HEAD
  username: String,
  password: {
    type: String,
    default: "123456"
  },
  role: {
    type: mongoose.Types.ObjectId,
    ref: "Role"
  },
  phone: String,
  rid: {
    type: mongoose.Types.ObjectId,
    ref: "Roles"
  },
  oid: {
    type: mongoose.Types.ObjectId,
    ref: "Organization"
  },
  // 分公司
  // org: String,
  // 部门
  partid: {
    type: mongoose.Types.ObjectId,
    ref: "Organization"
  },
  card: Number,
  status: {
    type: Boolean,
    default: true
  },
  buildtime: {
    type: Date,
    default: Date.now
  },
  changetime: {
    type: Date,
    default: Date.now
  },
  type: String,
  desc: String,
  month: Number,
  day: Number
});
=======
    username:String,
    password: {
        type: String,
        default: '123456'
    },
    role:{
        type:mongoose.Types.ObjectId,
        ref:'Role'
    },
    phone: String,
    rid: {
        type: mongoose.Types.ObjectId,
        ref: 'Roles'
    },
    oid: {
        type: mongoose.Types.ObjectId,
        ref: 'Organization'
    },
    // 分公司
    // org: String, 
    // 部门
    partid: {
        type: mongoose.Types.ObjectId,
        ref: 'Organization'
    },
    card: Number,
    status: {
        type: Boolean,
        default: true
    },
    buildtime: {
        type: Date,
        default: Date.now
    },
    changetime: {
        type: Date,
        default: Date.now
    },
    type:String,
    desc: String,
    month: Number,
    day: Number,
})


const RolesSchema = new mongoose.Schema({
    name: String,
    oid: {
        type: mongoose.Types.ObjectId,
        ref: 'Organization'
    },
    buildtime: Date,
    changetime: Date,
    count: Number,
    desc: String,
    status: Boolean
})


const OrganizationSchema =  mongoose.Schema({
    name:String,
    type: String,
    pid: {
        type: mongoose.Types.ObjectId,
        ref: 'Organization'
    },
    employees: Number,
    buildtime: {
        type: Date,
        default: Date.now
    },
    changetime: {
        type: Date,
        default: Date.now
    },
    status: {
        type: Boolean,
        default: true
    },
    desc: String,
})
>>>>>>> 40cb69444077c79252235744ae50d4b0bd554708

const OrganizationSchema = mongoose.Schema({
  name: String,
  type: String,
  pid: {
    type: mongoose.Types.ObjectId,
    ref: "Organization"
  },
  employees: Number,
  buildtime: {
    type: Date,
    default: Date.now
  },
  changetime: {
    type: Date,
    default: Date.now
  },
  status: {
    type: Boolean,
    default: true
  },
  desc: String,
  type: {
    type: String,
    default: "正式员工"
  }
});



// 角色岗位
<<<<<<< HEAD
const RolesSchema = new mongoose.Schema({
  name: String,
  oid: {
    type: mongoose.Types.ObjectId,
    ref: "Organization"
  },
  buildtime: Date,
  changetime: Date,
  count: Number,
  desc: String,
  status: Boolean
});
const date = new Date();
=======

const date = new Date()
>>>>>>> 40cb69444077c79252235744ae50d4b0bd554708
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, "0"); // 月份从0开始，需要加1，并确保两位数
const day = date.getDate().toString().padStart(2, "0"); // 确保两位数
const hours = date.getHours().toString().padStart(2, "0"); // 确保两位数
const minutes = date.getMinutes().toString().padStart(2, "0"); // 确保两位数
const seconds = date.getSeconds().toString().padStart(2, "0");
const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;

const scheduleSchema = mongoose.Schema({
  scheduleName: String,
  scheduleType: String,
  upTime: {
    type: String,
    default: formattedDate
  },
  createTime: {
    type: String,
    default: formattedDate
  },
  createPeople: {
    type: String,
    default: "管理员"
  }
});

<<<<<<< HEAD
const schedule = mongoose.model("schedule", scheduleSchema);
const Menu = mongoose.model("Menu", MenuSchema);
const Role = mongoose.model("Role", RoleSchema);
const User = mongoose.model("User", UserSchema);
const Organization = mongoose.model("Organization", OrganizationSchema);
const Roles = mongoose.model("Roles", RolesSchema, "Roles");
//创建排班表
const Classes = mongoose.model("classes", ClassesSchema);

module.exports = { Menu, Role, User, Classes, schedule, Organization, Roles };
=======

const schedule = mongoose.model('schedule',scheduleSchema)
const Menu = mongoose.model('Menu',MenuSchema)
const Role = mongoose.model('Role',RoleSchema)
const User = mongoose.model('User', UserSchema)
const Organization = mongoose.model('Organization', OrganizationSchema)
const Roles = mongoose.model('Roles', RolesSchema, 'Roles')



//创建排班表
const Classes = mongoose.model("classes", ClassesSchema);
// const zsy = mongoose.model("zsy", zsySchema);

module.exports = { Menu, Role, User,Classes,Organization,Roles,schedule };
>>>>>>> 40cb69444077c79252235744ae50d4b0bd554708
